package com.ruoyi.common.utils.poi.word.render;

import cn.hutool.core.util.EnumUtil;
import com.ruoyi.common.utils.poi.word.render.business.T0101Handler;
import com.ruoyi.common.utils.poi.word.render.business.T0102Handler;
import java.util.HashMap;
import java.util.Map;

/**
 * 模板常量
 * D:/ruoyi/uploadPath/template
 */
public enum TemplateEnum {

    /**
     * 图片转pdf - 不在这儿统一生成
     */
    T0101("T0101", "建议报告单", T0101Handler.class, "/建议报告单.docx"),

    /**
     * 专家服务绩效评定表（综合性活动使用）帮扶组两人以上签字、督查处负责人签字、
     */
    T0102("T0102", "综合活动专家服务绩效评定表", T0102Handler.class, "/T0102.docx"),

    ;
    private String code;
    private String value;
    private String path;

    private Map<String, Object> ext = new HashMap<>();

    private boolean canEdit = false;

    private Class<?> handle = WordRenderHandler.class;

    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public boolean isCanEdit() {
        return canEdit;
    }

    public Class<?> getHandle() {
        return handle;
    }

    public Map<String, Object> getExt() {
        return ext;
    }

    public void setExt(Map<String, Object> ext) {
        this.ext = ext;
    }

    public void setHandle(Class<?> handle) {
        this.handle = handle;
    }

    TemplateEnum(String code, String value, Class<?> handle, String path) {
        this.code = code;
        this.value = value;
        this.handle = handle;
        this.path = path;
    }

    TemplateEnum(String code, String value, Class<?> handle, boolean canEdit) {
        this.code = code;
        this.value = value;
        this.handle = handle;
        this.canEdit = canEdit;
    }

    public static TemplateEnum getByCode(String code) {
        TemplateEnum template = EnumUtil.getBy(TemplateEnum::getCode, code);
        return template;
    }

    public static TemplateEnum getByName(String name) {
        TemplateEnum template = EnumUtil.getBy(TemplateEnum::name, name);
        return template;
    }

    public String getPath() {
        return path;
    }
}
